<script setup>
import TodoList from './components/TodoList.vue'
import Counter from './components/Counter.vue'
import Documentation from './components/Documentation.vue'
import QuickStart from './components/QuickStart.vue'
import ProjectStructure from './components/ProjectStructure.vue'
import { ref } from 'vue'

const currentExample = ref('quickstart')
</script>

<template>
  <header>
    <img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
    <h1>Vue 初学者示例项目</h1>
  </header>

  <main>
    <div class="examples-nav">
      <button 
        @click="currentExample = 'quickstart'" 
        :class="{ active: currentExample === 'quickstart' }"
      >
        快速入门
      </button>
      <button 
        @click="currentExample = 'todo'" 
        :class="{ active: currentExample === 'todo' }"
      >
        待办事项列表
      </button>
      <button 
        @click="currentExample = 'counter'" 
        :class="{ active: currentExample === 'counter' }"
      >
        计数器
      </button>
      <button 
        @click="currentExample = 'docs'" 
        :class="{ active: currentExample === 'docs' }"
      >
        使用文档
      </button>
      <button 
        @click="currentExample = 'structure'" 
        :class="{ active: currentExample === 'structure' }"
      >
        项目结构
      </button>
    </div>

    <QuickStart v-if="currentExample === 'quickstart'" />
    <TodoList v-else-if="currentExample === 'todo'" />
    <Counter v-else-if="currentExample === 'counter'" />
    <Documentation v-else-if="currentExample === 'docs'" />
    <ProjectStructure v-else-if="currentExample === 'structure'" />
  </main>

  <footer>
    <p>这个示例项目展示了Vue 3的基本用法，适合初学者学习。查看文档页面获取更多指引。</p>
  </footer>
</template>

<style>
#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  font-weight: normal;
}

header {
  line-height: 1.5;
  text-align: center;
  margin-bottom: 2rem;
}

.logo {
  display: block;
  margin: 0 auto 1rem;
}

h1 {
  color: #42b983;
  font-size: 2rem;
  margin-top: 1rem;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.examples-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.examples-nav button {
  padding: 10px 15px;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s;
  opacity: 0.8;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.examples-nav button:hover {
  background-color: #3aa876;
  transform: translateY(-2px);
}

.examples-nav button.active {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

footer {
  margin-top: 40px;
  text-align: center;
  color: #666;
  font-size: 14px;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

@media (min-width: 1024px) {
  body {
    display: flex;
    place-items: center;
  }

  #app {
    padding: 0 2rem;
  }
}

/* 全局基础字体设置 */
body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f7fa;
}
</style>
